﻿using System;
using System.Collections.Generic;

namespace CID.Web.Support
{
    internal static class Styling
    {
        private const string ClassSeparator = " ";
        private const string HtmlClassAttribute = "class";
        public const string TextBoxClass = "text-box";
        public const string MultiLineClass = "multi-line";
        public const string ComboBoxClass = "combo-box";

        public static IDictionary<string, object> DecorateWithClass(this IDictionary<string, object> htmlAttributes, params string[] classes)
        {
            if (htmlAttributes == null) htmlAttributes = new Dictionary<string, object>();
            if (!htmlAttributes.ContainsKey(HtmlClassAttribute)) htmlAttributes.Add(HtmlClassAttribute, String.Empty);

            var htmlClass = htmlAttributes[HtmlClassAttribute].ToString();
            htmlClass = htmlClass + (String.IsNullOrEmpty(htmlClass) ? String.Empty : ClassSeparator) + String.Join(ClassSeparator, classes);
            htmlAttributes[HtmlClassAttribute] = htmlClass;

            return htmlAttributes;
        }
    }
}